//
//  LSZDynamicOtherViewController.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/24.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZDynamicOtherViewController.h"

#import "TYCyclePagerView.h"
#import "TYCyclePagerViewCell.h"
#import "TYPageControl.h"
#import "LCCycleModel.h"
#import "LSZDynamicOtherViewController+LCCycle.h"

@interface LSZDynamicOtherViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView * tableViewOther;
@property(nonatomic,strong) LSZListTopicsManager * listTopicsManager;
@property(nonatomic,strong) LSZDynamicClassificationManager * classManager;

 
@end

@implementation LSZDynamicOtherViewController
#pragma mark - 话题的数据
//-(void)getDataList
//{
//    __weak typeof(self) weakSelf = self;
//    [LSZRequestResolutionDic getListOfTopics:@"0" :^(BOOL isOK, NSString * string, LSZListTopicsManager * manager) {
//        if (isOK == YES) {
//            if (manager.arrayData.count == 0) {
//                weakSelf.tableViewOther.mj_footer.hidden = YES;
//                LSZEmptyDataVC * emptyDataVC = [[LSZEmptyDataVC alloc]init];
//                [emptyDataVC showWithView:weakSelf.tableViewOther];
//            }
//            self.listTopicsManager = manager;
//            [self.tableViewOther reloadData];
//        }else{
//            [self initWithtring:string];
//        }
//    }];
//}
#pragma mark - 获取分类
-(void)forClassification
{
    [LSZRequestResolutionDic publishDynamicCategorization:^(BOOL isOk, NSString * string, LSZDynamicClassificationManager * ClassManager) {
        if (isOk == YES) {
            self.classManager = ClassManager;
            [self.tableViewOther reloadData];
        }
    }];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"更多";
//    [self getDataList];
    [self forClassification];
    [self.tableViewOther registerClass:[LSZMoreTopicsTableViewCell class] forCellReuseIdentifier:@"LSZMoreTopicsTableViewCell"];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//    CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:210 :10];
//    return height;
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (self.listTopicsManager.arrayData.count >0  && indexPath.row == 0) {
//        return 100;
//    }else{
//        CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:78 :4];
//        return height;
//    }
    CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:78 :4];
    return height;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.001;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.classManager.mutMgArray.count;

//    if (self.listTopicsManager.arrayData.count >0 &&self.classManager.mutMgArray.count >0) {
//        return 1+self.classManager.mutMgArray.count;
//    }else if (self.listTopicsManager.arrayData.count == 0 &&self.classManager.mutMgArray.count == 0){
//        return 0;
//    }else if (self.listTopicsManager.arrayData.count == 0&& self.classManager.mutMgArray.count > 0){
//        return self.classManager.mutMgArray.count;
//    }
//    else{
//        return 1;
//    }
//    return 10;
}
//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
//{
//    UITableViewHeaderFooterView *  cycleScrollViewContainer = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"header"];
//    if (!cycleScrollViewContainer) {
//        cycleScrollViewContainer = [[UITableViewHeaderFooterView alloc]initWithReuseIdentifier:@"header"];
//        CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:210 :10];
//
//        if (self.pagerView == nil) {
////            UIImageView *bgimageView = [[UIImageView alloc] init];
////            self.bgimageView = bgimageView;
////            bgimageView.image = [UIImage imageNamed:@"devotion_bannerB"];
////            [cycleScrollViewContainer insertSubview:bgimageView atIndex:0];
////            _bgimageView.frame = CGRectMake(0,0, ScreenWidth, height);
////            [_bgimageView.layer setMasksToBounds:YES];
////            [_bgimageView.layer setCornerRadius:4];
//            [self loadDataWithPage:NO];
//            [cycleScrollViewContainer addSubview:[self setupCycleWithCycleHeight:height]];
//        }
//        self.pagerView.tag = 10001;
//    }
//    return cycleScrollViewContainer;
//}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZMoreTopicsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZMoreTopicsTableViewCell" forIndexPath:indexPath];
    LSZDynamicClassificationMg * mg = nil;
    mg = self.classManager.mutMgArray[indexPath.row];
    cell.dynamicClassificationMg = mg;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
//    if (self.listTopicsManager.arrayData.count >0 && indexPath.row == 0) {
//        LSZHotTopicTableViewCell * cell = [[LSZHotTopicTableViewCell alloc]initWithHotToPic:self.listTopicsManager.arrayData];
//        cell.hotCollectionVC.pushNewBlock = ^(NSInteger rowNumber) {
//            LSZListTopicsMg * mg = nil;
//            mg = self.listTopicsManager.arrayData[rowNumber];
//            LSZReleaseDynamicVC * VC = [[LSZReleaseDynamicVC alloc]init];
//            VC.theme = mg.id_id;
//            VC.themeStr = mg.content;
//            VC.cname = mg.cname;
//            VC.kind = mg.cate;
//            [self.navigationController pushViewController:VC animated:YES];
//        };
//        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        return cell;
//    }else{
//        if (self.listTopicsManager.arrayData.count==0) {
//            //没有话题
//            LSZMoreTopicsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZMoreTopicsTableViewCell" forIndexPath:indexPath];
//            LSZDynamicClassificationMg * mg = nil;
//            mg = self.classManager.mutMgArray[indexPath.row];
//            cell.dynamicClassificationMg = mg;
//            cell.selectionStyle = UITableViewCellSelectionStyleNone;
//            return cell;
//        }else{
//            //有话题 有分类
//            LSZMoreTopicsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZMoreTopicsTableViewCell" forIndexPath:indexPath];
//            LSZDynamicClassificationMg * mg = nil;
//            mg = self.classManager.mutMgArray[indexPath.row-1];
//            cell.dynamicClassificationMg = mg;
//            cell.selectionStyle = UITableViewCellSelectionStyleNone;
//            return cell;
//        }
//    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZDynamicClassificationMg * mg = nil;
    mg = self.classManager.mutMgArray[indexPath.row];
    LSZDynamicRealTimeSelectionVC * vc = [[LSZDynamicRealTimeSelectionVC alloc]init];
    vc.kind = mg.id_id;
    vc.images = mg.images;
    vc.cname = mg.name;//分类
    vc.theme = @"";//话题id
    vc.themeStr = @"";//话题
    vc.typeDescription = mg.discrib;
    [self.navigationController pushViewController:vc animated:YES];
//    if (self.listTopicsManager.arrayData.count >0 && indexPath.row > 0) {
//        LSZDynamicClassificationMg * mg = nil;
//        mg = self.classManager.mutMgArray[indexPath.row-1];
//        LSZDynamicRealTimeSelectionVC * vc = [[LSZDynamicRealTimeSelectionVC alloc]init];
//        vc.kind = mg.id_id;
//        vc.images = mg.images;
//        [self.navigationController pushViewController:vc animated:YES];
//    }
}
-(UITableView *)tableViewOther
{
    if (_tableViewOther == nil) {
        _tableViewOther = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
        _tableViewOther.delegate = self;
        _tableViewOther.dataSource = self;
        _tableViewOther.separatorColor = divider;
        _tableViewOther.estimatedRowHeight =0;
        _tableViewOther.estimatedSectionFooterHeight =0;
        _tableViewOther.estimatedSectionHeaderHeight =0;
        _tableViewOther.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
        _tableViewOther.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self.view addSubview:_tableViewOther];
    }
    return _tableViewOther;
}

@end
